package inc;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

public class Data implements Parcelable {
	private List<Trip> trips;

	public Data() {
		this.trips = new ArrayList<Trip>();
	}

	public List<Trip> getTrips() {
		return trips;
	}

	public void setTrips(List<Trip> trips) {
		this.trips = trips;
	}

	public void addTrip(Trip trip) {
		this.trips.add(trip);
	}

	public void removeTrip(Trip trip) {
		int location = this.trips.indexOf(trip);
		this.trips.remove(location);
	}

	// parcel methods

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeList(trips);
	}

	
	@SuppressWarnings("unchecked")
	public Data(Parcel in) {
		trips = in.readArrayList(Trip.class.getClassLoader());
	}
	
	
	public static final Parcelable.Creator<Data> CREATOR = new Parcelable.Creator<Data>() {
		public Data createFromParcel(Parcel in) {
			return new Data(in);
		}

		public Data[] newArray(int size) {
			return new Data[size];
		}
	};
	
	
	
	
	///////////////
	
	public void print()
	{
		for(Trip t : this.trips)
			System.out.println("sum ="+t.getSum()+"\ntrip name = "+t.getTrip_name()+"\nmembers = "+t.getMembers().toString());
	}
}
